﻿#define _CRT_SECURE_NO_WARNINGS 1

//编程初学者入门训练第七十七题
//BC79 图像相似度
//https://www.nowcoder.com/practice/f2952ee3bb5c48a9be6c261e29dd1092?tpId=107&tqId=33360&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D107&difficulty=undefined&judgeStatus=undefined&tags=&title=

#include <stdio.h>
#include <stdlib.h>
int main() {
    //图像的本质是二进制一个像素点代表一个二进制
    //一张图片用一个二维数组表示
    int row = 0;//行
    int col = 0;//列
    scanf("%d %d", &row, &col);
    //创建两个图像数组
    int arr1[100][100] = { 0 };
    int arr2[100][100] = { 0 };

    //输入
    for (int i = 0; i < row; i++) {
        for (int j = 0; j < col; j++) {
            scanf("%d ", &arr1[i][j]);
        }
    }
    for (int i = 0; i < row; i++) {
        for (int j = 0; j < col; j++) {
            scanf("%d ", &arr2[i][j]);
        }
    }

    int count = 0;//表示相同的二进制个数
    //比较
    for (int i = 0; i < row; i++) {
        for (int j = 0; j < col; j++) {
            if (arr1[i][j] == arr2[i][j]) {
                count++;
            }
        }
    }
    //输出
    printf("%.2f\n", 100.0 * count / (row * col));

    return 0;
}